.class public Lcom/instagram/pendingmedia/b/c;
.super Ljava/lang/Object;
.source "PendingMediaStoreSerializer.java"


# static fields
.field private static a:Lcom/instagram/pendingmedia/b/c;


# instance fields
.field private final b:Landroid/content/Context;

.field private c:Lcom/fasterxml/jackson/databind/ObjectMapper;

.field private volatile d:Z

.field private final e:Ljava/util/List;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/util/List",
            "<",
            "Ljava/lang/Runnable;",
            ">;"
        }
    .end annotation
.end field


# direct methods
.method private constructor <init>()V
    .locals 3

    .prologue
    const/4 v2, 0x0

    .line 51
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 36
    iput-boolean v2, p0, Lcom/instagram/pendingmedia/b/c;->d:Z

    .line 37
    new-instance v0, Ljava/util/LinkedList;

    invoke-direct {v0}, Ljava/util/LinkedList;-><init>()V

    iput-object v0, p0, Lcom/instagram/pendingmedia/b/c;->e:Ljava/util/List;

    .line 52
    invoke-static {}, Lcom/instagram/e/a/a;->a()Landroid/content/Context;

    move-result-object v0

    iput-object v0, p0, Lcom/instagram/pendingmedia/b/c;->b:Landroid/content/Context;

    .line 53
    new-instance v0, Lcom/instagram/pendingmedia/b/e;

    const/4 v1, 0x0

    invoke-direct {v0, p0, v1}, Lcom/instagram/pendingmedia/b/e;-><init>(Lcom/instagram/pendingmedia/b/c;Lcom/instagram/pendingmedia/b/d;)V

    new-array v1, v2, [Ljava/lang/Void;

    invoke-virtual {v0, v1}, Lcom/instagram/pendingmedia/b/e;->c([Ljava/lang/Object;)Lcom/instagram/d/a;

    .line 54
    return-void
.end method

.method static synthetic a(Lcom/instagram/pendingmedia/b/c;)Landroid/content/Context;
    .locals 1
    .parameter

    .prologue
    .line 28
    iget-object v0, p0, Lcom/instagram/pendingmedia/b/c;->b:Landroid/content/Context;

    return-object v0
.end method

.method public static a()Lcom/instagram/pendingmedia/b/c;
    .locals 1

    .prologue
    .line 40
    sget-object v0, Lcom/instagram/pendingmedia/b/c;->a:Lcom/instagram/pendingmedia/b/c;

    if-nez v0, :cond_0

    .line 41
    invoke-static {}, Lcom/instagram/pendingmedia/b/c;->d()V

    .line 43
    :cond_0
    sget-object v0, Lcom/instagram/pendingmedia/b/c;->a:Lcom/instagram/pendingmedia/b/c;

    return-object v0
.end method

.method static synthetic a(Lcom/instagram/pendingmedia/b/c;Z)Z
    .locals 0
    .parameter
    .parameter

    .prologue
    .line 28
    iput-boolean p1, p0, Lcom/instagram/pendingmedia/b/c;->d:Z

    return p1
.end method

.method static synthetic b(Lcom/instagram/pendingmedia/b/c;)Lcom/fasterxml/jackson/databind/ObjectMapper;
    .locals 1
    .parameter

    .prologue
    .line 28
    invoke-direct {p0}, Lcom/instagram/pendingmedia/b/c;->e()Lcom/fasterxml/jackson/databind/ObjectMapper;

    move-result-object v0

    return-object v0
.end method

.method static synthetic c(Lcom/instagram/pendingmedia/b/c;)Ljava/util/List;
    .locals 1
    .parameter

    .prologue
    .line 28
    iget-object v0, p0, Lcom/instagram/pendingmedia/b/c;->e:Ljava/util/List;

    return-object v0
.end method

.method private static declared-synchronized d()V
    .locals 2

    .prologue
    .line 47
    const-class v1, Lcom/instagram/pendingmedia/b/c;

    monitor-enter v1

    :try_start_0
    sget-object v0, Lcom/instagram/pendingmedia/b/c;->a:Lcom/instagram/pendingmedia/b/c;
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    if-eqz v0, :cond_0

    .line 49
    :goto_0
    monitor-exit v1

    return-void

    .line 48
    :cond_0
    :try_start_1
    new-instance v0, Lcom/instagram/pendingmedia/b/c;

    invoke-direct {v0}, Lcom/instagram/pendingmedia/b/c;-><init>()V

    sput-object v0, Lcom/instagram/pendingmedia/b/c;->a:Lcom/instagram/pendingmedia/b/c;
    :try_end_1
    .catchall {:try_start_1 .. :try_end_1} :catchall_0

    goto :goto_0

    .line 47
    :catchall_0
    move-exception v0

    monitor-exit v1

    throw v0
.end method

.method private e()Lcom/fasterxml/jackson/databind/ObjectMapper;
    .locals 1

    .prologue
    .line 197
    iget-object v0, p0, Lcom/instagram/pendingmedia/b/c;->c:Lcom/fasterxml/jackson/databind/ObjectMapper;

    if-nez v0, :cond_0

    .line 198
    invoke-static {}, Lcom/instagram/pendingmedia/a/l;->a()Lcom/fasterxml/jackson/databind/ObjectMapper;

    move-result-object v0

    iput-object v0, p0, Lcom/instagram/pendingmedia/b/c;->c:Lcom/fasterxml/jackson/databind/ObjectMapper;

    .line 200
    :cond_0
    iget-object v0, p0, Lcom/instagram/pendingmedia/b/c;->c:Lcom/fasterxml/jackson/databind/ObjectMapper;

    return-object v0
.end method


# virtual methods
.method public a(Ljava/lang/Runnable;)V
    .locals 2
    .parameter

    .prologue
    .line 183
    iget-boolean v0, p0, Lcom/instagram/pendingmedia/b/c;->d:Z

    if-eqz v0, :cond_0

    .line 184
    invoke-interface {p1}, Ljava/lang/Runnable;->run()V

    .line 194
    :goto_0
    return-void

    .line 186
    :cond_0
    iget-object v1, p0, Lcom/instagram/pendingmedia/b/c;->e:Ljava/util/List;

    monitor-enter v1

    .line 187
    :try_start_0
    iget-boolean v0, p0, Lcom/instagram/pendingmedia/b/c;->d:Z

    if-eqz v0, :cond_1

    .line 188
    invoke-interface {p1}, Ljava/lang/Runnable;->run()V

    .line 192
    :goto_1
    monitor-exit v1

    goto :goto_0

    :catchall_0
    move-exception v0

    monitor-exit v1
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    throw v0

    .line 190
    :cond_1
    :try_start_1
    iget-object v0, p0, Lcom/instagram/pendingmedia/b/c;->e:Ljava/util/List;

    invoke-interface {v0, p1}, Ljava/util/List;->add(Ljava/lang/Object;)Z
    :try_end_1
    .catchall {:try_start_1 .. :try_end_1} :catchall_0

    goto :goto_1
.end method

.method public b()V
    .locals 2

    .prologue
    .line 60
    new-instance v0, Ljava/lang/Thread;

    new-instance v1, Lcom/instagram/pendingmedia/b/d;

    invoke-direct {v1, p0}, Lcom/instagram/pendingmedia/b/d;-><init>(Lcom/instagram/pendingmedia/b/c;)V

    invoke-direct {v0, v1}, Ljava/lang/Thread;-><init>(Ljava/lang/Runnable;)V

    invoke-virtual {v0}, Ljava/lang/Thread;->start()V

    .line 66
    return-void
.end method

.method public declared-synchronized c()V
    .locals 5

    .prologue
    .line 73
    monitor-enter p0

    :try_start_0
    iget-object v0, p0, Lcom/instagram/pendingmedia/b/c;->b:Landroid/content/Context;

    const-string v1, "pending_media.json"

    invoke-virtual {v0, v1}, Landroid/content/Context;->deleteFile(Ljava/lang/String;)Z

    .line 76
    new-instance v2, Ljava/util/ArrayList;

    invoke-direct {v2}, Ljava/util/ArrayList;-><init>()V

    .line 77
    invoke-static {}, Lcom/instagram/pendingmedia/b/a;->a()Lcom/instagram/pendingmedia/b/a;

    move-result-object v0

    iget-object v0, v0, Lcom/instagram/pendingmedia/b/a;->a:Ljava/util/Map;

    invoke-interface {v0}, Ljava/util/Map;->values()Ljava/util/Collection;

    move-result-object v0

    invoke-interface {v0}, Ljava/util/Collection;->iterator()Ljava/util/Iterator;

    move-result-object v1

    :cond_0
    :goto_0
    invoke-interface {v1}, Ljava/util/Iterator;->hasNext()Z

    move-result v0

    if-eqz v0, :cond_1

    invoke-interface {v1}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Lcom/instagram/pendingmedia/model/c;

    .line 79
    invoke-virtual {v0}, Lcom/instagram/pendingmedia/model/c;->w()Lcom/instagram/pendingmedia/model/e;

    move-result-object v3

    sget-object v4, Lcom/instagram/pendingmedia/model/e;->c:Lcom/instagram/pendingmedia/model/e;

    if-eq v3, v4, :cond_0

    .line 80
    invoke-virtual {v2, v0}, Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    goto :goto_0

    .line 73
    :catchall_0
    move-exception v0

    monitor-exit p0

    throw v0

    .line 85
    :cond_1
    :try_start_1
    invoke-virtual {v2}, Ljava/util/ArrayList;->size()I
    :try_end_1
    .catchall {:try_start_1 .. :try_end_1} :catchall_0

    move-result v0

    if-nez v0, :cond_2

    .line 119
    :goto_1
    monitor-exit p0

    return-void

    .line 90
    :cond_2
    const/4 v1, 0x0

    .line 92
    :try_start_2
    iget-object v0, p0, Lcom/instagram/pendingmedia/b/c;->b:Landroid/content/Context;

    const-string v3, "pending_media.json"

    const/4 v4, 0x0

    invoke-virtual {v0, v3, v4}, Landroid/content/Context;->openFileOutput(Ljava/lang/String;I)Ljava/io/FileOutputStream;
    :try_end_2
    .catchall {:try_start_2 .. :try_end_2} :catchall_0
    .catch Ljava/io/FileNotFoundException; {:try_start_2 .. :try_end_2} :catch_0

    move-result-object v0

    move-object v1, v0

    .line 97
    :goto_2
    if-nez v1, :cond_3

    .line 98
    :try_start_3
    const-string v0, "PendingMediaStoreSerializer"

    const-string v1, "Failed to acquire output stream for pending_media.json"

    invoke-static {v0, v1}, Lcom/facebook/e/a/a;->e(Ljava/lang/String;Ljava/lang/String;)V

    goto :goto_1

    .line 93
    :catch_0
    move-exception v0

    .line 94
    const-string v3, "PendingMediaStoreSerializer"

    const-string v4, "File not found while getting output stream for pending_media.json"

    invoke-static {v3, v4, v0}, Lcom/facebook/e/a/a;->d(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)V
    :try_end_3
    .catchall {:try_start_3 .. :try_end_3} :catchall_0

    goto :goto_2

    .line 103
    :cond_3
    :try_start_4
    const-string v0, "PendingMediaStoreSerializer"

    new-instance v3, Ljava/lang/StringBuilder;

    invoke-direct {v3}, Ljava/lang/StringBuilder;-><init>()V

    const-string v4, "Serializing "

    invoke-virtual {v3, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v3

    invoke-virtual {v2}, Ljava/util/ArrayList;->size()I

    move-result v4

    invoke-virtual {v3, v4}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    move-result-object v3

    const-string v4, " entries: "

    invoke-virtual {v3, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v3

    invoke-virtual {v3}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v3

    invoke-static {v0, v3}, Lcom/facebook/e/a/a;->b(Ljava/lang/String;Ljava/lang/String;)V

    .line 105
    invoke-static {}, Lcom/instagram/i/a;->b()Z

    move-result v0

    if-eqz v0, :cond_4

    .line 106
    invoke-virtual {v2}, Ljava/util/ArrayList;->iterator()Ljava/util/Iterator;

    move-result-object v3

    :goto_3
    invoke-interface {v3}, Ljava/util/Iterator;->hasNext()Z

    move-result v0

    if-eqz v0, :cond_4

    invoke-interface {v3}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Lcom/instagram/pendingmedia/model/c;

    .line 107
    const-string v4, "PendingMediaStoreSerializer"

    invoke-virtual {v0}, Lcom/instagram/pendingmedia/model/c;->toString()Ljava/lang/String;

    move-result-object v0

    invoke-static {v4, v0}, Lcom/facebook/e/a/a;->b(Ljava/lang/String;Ljava/lang/String;)V
    :try_end_4
    .catchall {:try_start_4 .. :try_end_4} :catchall_1
    .catch Ljava/io/IOException; {:try_start_4 .. :try_end_4} :catch_1

    goto :goto_3

    .line 111
    :catch_1
    move-exception v0

    .line 112
    :try_start_5
    const-string v2, "PendingMediaStoreSerializer"

    const-string v3, "Exception while writing out pending_media.json"

    invoke-static {v2, v3, v0}, Lcom/facebook/e/a/a;->d(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)V
    :try_end_5
    .catchall {:try_start_5 .. :try_end_5} :catchall_1

    .line 115
    :try_start_6
    invoke-virtual {v1}, Ljava/io/FileOutputStream;->close()V
    :try_end_6
    .catchall {:try_start_6 .. :try_end_6} :catchall_0
    .catch Ljava/io/IOException; {:try_start_6 .. :try_end_6} :catch_2

    goto :goto_1

    .line 116
    :catch_2
    move-exception v0

    goto :goto_1

    .line 110
    :cond_4
    :try_start_7
    invoke-direct {p0}, Lcom/instagram/pendingmedia/b/c;->e()Lcom/fasterxml/jackson/databind/ObjectMapper;

    move-result-object v0

    invoke-virtual {v0, v1, v2}, Lcom/fasterxml/jackson/databind/ObjectMapper;->writeValue(Ljava/io/OutputStream;Ljava/lang/Object;)V
    :try_end_7
    .catchall {:try_start_7 .. :try_end_7} :catchall_1
    .catch Ljava/io/IOException; {:try_start_7 .. :try_end_7} :catch_1

    .line 115
    :try_start_8
    invoke-virtual {v1}, Ljava/io/FileOutputStream;->close()V
    :try_end_8
    .catchall {:try_start_8 .. :try_end_8} :catchall_0
    .catch Ljava/io/IOException; {:try_start_8 .. :try_end_8} :catch_3

    goto :goto_1

    .line 116
    :catch_3
    move-exception v0

    goto :goto_1

    .line 114
    :catchall_1
    move-exception v0

    .line 115
    :try_start_9
    invoke-virtual {v1}, Ljava/io/FileOutputStream;->close()V
    :try_end_9
    .catchall {:try_start_9 .. :try_end_9} :catchall_0
    .catch Ljava/io/IOException; {:try_start_9 .. :try_end_9} :catch_4

    .line 117
    :goto_4
    :try_start_a
    throw v0
    :try_end_a
    .catchall {:try_start_a .. :try_end_a} :catchall_0

    .line 116
    :catch_4
    move-exception v1

    goto :goto_4
.end method
